package String.s8;

public class test_334 {
    public static void main(String[] args) {
        int[] nums={1,2,3,4,5};
        System.out.println(new Solution().increasingTriplet(nums));
    }
}
class Solution {
    public boolean increasingTriplet(int[] nums) {
        int n = nums.length;
        if (n < 3) {
            return false;
        }
        int first = nums[0], second = Integer.MAX_VALUE;
        for (int i = 1; i < n; i++) {
            int num = nums[i];
            if (num > second) {//如果当前值大于second，说明存在三个数，first<second<num，返回true
                return true;
            } else if (num > first) {//如果当前值大于first，所以更新second,存在两个数first<second
                second = num;
            } else {//如果当前值小于first，所以更新first
                first = num;
            }
        }
        return false;
    }
}
